//
//  ListClass.cpp
//  Practice10
//
//  Created by 赵世杰 on 2020/7/25.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#include "ListClass.hpp"
#include <iostream>

using namespace std;


List::List()
{
    top = 0;
}

bool List::add(const Item &item)
{
    if(top < MAX)
    {
        items[top++] = item;
        
        return true;
    }
    else
    {
        return false;
    }
}

bool List::isempty() const
{
    return top == 0;
}

bool List::isfull() const
{
    return top == MAX;
}

void List::visit(void (*pf)(Item &item))
{
    for (int i=0; i<top; i++)
    {
        pf(items[i]);
    }
}

void List::showList() const
{
    cout << "The list is: ";
    for (int i = 0; i< top; i++)
    {
        cout << items[i] << " ";
    }
    cout << endl << endl;
    
}


void db(Item &item)
{
    item *= 2;
    
}



